import request from '../request'

export interface Spot {
  spotId: number
  spotName: string
  spotDescription: string
}

export interface Route {
  routeId?: number
  routeName: string
  price: number
  routeDescription: string
  spots?: Spot[]
  spotsIds?: number[]
}

export interface SpotForm {
  spotName: string
  spotDescription: string
}

export const routeApi = {
  // 获取所有线路
  getAllRoutes: () => 
    request.get('/travel_route/get_all_travel_route'),
    
  // 获取单个线路
  getRouteById: (id: number) => 
    request.get(`/travel_route/get_travel_route/${id}`),
    
  // 新增线路
  addRoute: (data: Route) => 
    request.post('/travel_route/post_travel_route', data),
    
  // 获取所有景点
  getAllSpots: () =>
    request.get('/travel_route/get_all_spots'),
    
  // 新增景点
  addSpot: (data: SpotForm) => 
    request.post('/travel_route/post_spots', data)
} 